
package system.base;

import framework.core.*;
import system.data.*;
/*
	Author    :chengbiao.he
	CreateTime:2008-02-19 11:08:22
*/
public class ClientDownupfileInfoSrv extends IHandler
{

	public ClientDownupfileInfoSrv() 
	{
		super();
	}
	private void deleteClientDownupfileInfo(DBConnection con,SrvContext context) throws Exception
	{
		String[] ids = context.getParameterValues("ids");
		ClientDownupfileInfo obj = null;
		for(int i=0;i<ids.length;i++)
		{
			obj = ClientDownupfileInfo.fetch(con,ids[i]);
			if(obj!=null) obj.delete(con);
		}
	}
	private void saveClientDownupfileInfo(DBConnection con,SrvContext context,ILoginContext loginContext) throws Exception
	{
		String id = context.getString("Id",null);
		ClientDownupfileInfo obj;
		if((id==null)||(id.equals("")))   //add
		{
			obj = ClientDownupfileInfo.fetch();
    	}
    	else                     //update
    	{
    		obj = ClientDownupfileInfo.fetch(con,id);
    	}
		ClientDownupfileInfoPageData data = (ClientDownupfileInfoPageData)PageData.fromForm(context,ClientDownupfileInfoPageData.class);
		context.setValue("ClientDownupfileInfoPageData",data);
		obj.fill(data);
		obj.save(con);
		//ClientDownupfileInfo cdfi = ClientDownupfileInfo.fetch(con,id);
		//cdfi.setDownloadtyp(v);
		//cdfi.setWarehouseUincode();
		//cdfi.
		
		
	}
	private void listClientDownupfileInfo(DBConnection con,SrvContext context,String path) throws Exception
	{
		ClientDownupfileInfoSearchEvent event = (ClientDownupfileInfoSearchEvent)SearchEvent.fromForm(context,ClientDownupfileInfoSearchEvent.class);
		context.setSessionValue("ClientDownupfileInfoSearchEvent",event);
		context.setNextUrl(path+"ClientDownupfileInfoList.jsp");
	}
	private void backClientDownupfileInfo(DBConnection con,SrvContext context,String path) throws Exception
	{
		context.setNextUrl(path+"ClientDownupfileInfoList.jsp");
	}
	
	public void doAction(DBConnection con,SrvContext context,ILoginContext loginContext) throws Exception
	{
		String action_code = context.getActionCode();
		String path = "/system/base/";
		
		if(action_code.equalsIgnoreCase("listClientDownupfileInfo"))
		{
			listClientDownupfileInfo(con,context,path);
			return;
		}
		if(action_code.equalsIgnoreCase("viewClientDownupfileInfo"))
		{
			String id = context.getString("Id",null);
			ClientDownupfileInfo obj = ClientDownupfileInfo.fetch(con,id);
			context.setValue("ClientDownupfileInfo",obj);
			context.setNextUrl(path+"ClientDownupfileInfoView.jsp");
			return;
		}
		if(action_code.equalsIgnoreCase("deleteClientDownupfileInfo"))
		{
			context.setErrorUrl(path+"ClientDownupfileInfoList.jsp");
			deleteClientDownupfileInfo(con,context);
			backClientDownupfileInfo(con,context,path);
			return;
		}
			
		if(action_code.equalsIgnoreCase("toAddClientDownupfileInfo"))
		{
			ClientDownupfileInfo obj = ClientDownupfileInfo.fetch();
			ClientDownupfileInfoPageData data = (ClientDownupfileInfoPageData)PageData.fromTable(obj,ClientDownupfileInfoPageData.class);
			context.setValue("ClientDownupfileInfoPageData",data);
			context.setNextUrl(path+"ClientDownupfileInfoEdit.jsp");
			return;
		}
		if(action_code.equalsIgnoreCase("toUpdateClientDownupfileInfo"))
		{
			String id = context.getString("Id",null);
			ClientDownupfileInfo obj = ClientDownupfileInfo.fetch(con,id);
			ClientDownupfileInfoPageData data = (ClientDownupfileInfoPageData)PageData.fromTable(obj,ClientDownupfileInfoPageData.class);
			context.setValue("ClientDownupfileInfoPageData",data);
			context.setNextUrl(path+"ClientDownupfileInfoEdit.jsp");
			return;
		}
		if(action_code.equalsIgnoreCase("toCopyClientDownupfileInfo"))
		{
			String id = context.getString("Id",null);
			ClientDownupfileInfo obj = ClientDownupfileInfo.copy(ClientDownupfileInfo.fetch(con,id));
			ClientDownupfileInfoPageData data = (ClientDownupfileInfoPageData)PageData.fromTable(obj,ClientDownupfileInfoPageData.class);
			context.setValue("ClientDownupfileInfoPageData",data);
			context.setNextUrl(path+"ClientDownupfileInfoEdit.jsp");
			return;
		}
		if(action_code.equalsIgnoreCase("saveClientDownupfileInfo"))
		{
			context.setErrorUrl(path+"ClientDownupfileInfoEdit.jsp");
			saveClientDownupfileInfo(con,context,loginContext);
			backClientDownupfileInfo(con,context,path);
			return;
		}
		if(action_code.equalsIgnoreCase("saveAndNewClientDownupfileInfo"))
		{
			context.setErrorUrl(path+"ClientDownupfileInfoEdit.jsp");
			saveClientDownupfileInfo(con,context,loginContext);
			ClientDownupfileInfo obj = ClientDownupfileInfo.fetch();
			ClientDownupfileInfoPageData data = (ClientDownupfileInfoPageData)PageData.fromTable(obj,ClientDownupfileInfoPageData.class);
			context.setValue("ClientDownupfileInfoPageData",data);
			context.setNextUrl(path+"ClientDownupfileInfoEdit.jsp");			
			return;
		}
		if(action_code.equalsIgnoreCase("backListClientDownupfileInfo"))
		{
			backClientDownupfileInfo(con,context,path);
			return;
		}
		
		//add by chengbiao.he start

		//add by chengbiao.he end

		Logger.throwException("ClientDownupfileInfoSrv","unknown action_code="+action_code);
	}
}
